<?php
/**
 * 合同系统参数
 */

namespace App\Service;

/**
 * 系统合同参数
 * @package App\Service
 */
class ContractParamsService
{
    //合同参数begin---------------------------------------------------------
    //----------合同类型-----------
    const CONTRACT_TYPE_CLGKXY = 'clgkxy';//车辆挂靠协议
    const CONTRACT_TYPE_HTCLXY = 'htclxy';//合同车辆协议
    const CONTRACT_TYPE_YDZFHT = 'ydzfht';//运单作废合同
    const CONTRACT_TYPE_YDBCHT = 'ydbcht';//运单补充合同
    const CONTRACT_TYPE_YDHT = 'ydht';//运单合同

    public static array $contract_types = [
        self::CONTRACT_TYPE_CLGKXY => '车辆挂靠协议',
        self::CONTRACT_TYPE_HTCLXY => '合同车辆协议',
        self::CONTRACT_TYPE_YDZFHT => '运单作废合同',
        self::CONTRACT_TYPE_YDBCHT => '运单补充合同',
        self::CONTRACT_TYPE_YDHT => '运单合同',
    ];
    //----------合同状态-----------
    const CONTRACT_STATUS_CREATED = 0;//新建
    const CONTRACT_STATUS_SIGNING = 1;//签署中
    const CONTRACT_STATUS_FINISHED = 2;//已完成
    const CONTRACT_STATUS_CANCELED = 3;//已撤销
    const CONTRACT_STATUS_EXPIRED = 5;//已过期
    const CONTRACT_STATUS_REJECTED = 7;//已拒签

    public static array $contract_status = [
        self::CONTRACT_STATUS_CREATED => '新建',
        self::CONTRACT_STATUS_SIGNING => '签署中',
        self::CONTRACT_STATUS_FINISHED => '已完成',
        self::CONTRACT_STATUS_CANCELED => '已撤销',
        self::CONTRACT_STATUS_EXPIRED => '已过期',
        self::CONTRACT_STATUS_REJECTED => '已拒签',
    ];
    //----------合同发起状态-----------
    const START_STATUS_0 = 0;
    const START_STATUS_1 = 1;
    const START_STATUS_2 = 2;
    public static $start_status = [
        self::START_STATUS_0 => '未发起',
        self::START_STATUS_1 => '已发起',
        self::START_STATUS_2 => '发起成功',
    ];

    //----------合同模板参数配置-----------
    public static function getContractTemplateConfig(array $contract_info, string $contract_type)
    {
        $contract_type = trim($contract_type);
        if (empty($contract_info) || !array_key_exists($contract_type, self::$contract_types)) return [];
        $config_data = [
            self::CONTRACT_TYPE_CLGKXY => [
                '甲方' => $contract_info['se_name'],
                '甲方代表' => $contract_info['se_person'],
                '甲方地址' => $contract_info['se_address'],
                '甲方电话' => $contract_info['se_mobile'],
                '乙方' => $contract_info['driver_name'],
                '乙方电话' => $contract_info['driver_mobile'],
                '乙方身份证号' => $contract_info['driver_id_card'],
                '乙方地址' => $contract_info['driver_address'],
                '车头号' => $contract_info['car_no'],
                '车架号' => $contract_info['vin'],
                '车挂号' => $contract_info['car_no_hang'],
                '车架车挂号' => $contract_info['hang_vin'],
                '新车挂靠费年' => $contract_info['from_year'],
                '新车挂靠费月' => $contract_info['from_month'],
                '新车挂靠费' => $contract_info['fir_fee'],
                '旧车判断年限' => $contract_info['car_year'],
                '旧车挂靠费' => $contract_info['sec_fee'],
            ],
            self::CONTRACT_TYPE_HTCLXY => [
                '甲方' => $contract_info['se_name'],
                '甲方代表' => $contract_info['se_person'],
                '甲方地址' => $contract_info['se_address'],
                '甲方电话' => $contract_info['se_mobile'],
                '乙方' => $contract_info['driver_name'],
                '乙方电话' => $contract_info['driver_mobile'],
                '乙方身份证号' => $contract_info['driver_id_card'],
                '车牌号' => $contract_info['car_no'],
                '新签货物保险' => $contract_info['PremiumFees1'],
                '新签管理费' => $contract_info['ManagementFees1'],
                '新签GPS温控设备费' => $contract_info['GPSFees1'],
                '新签费用合计' => $contract_info['TotalFees1'],
                '续签货物保险' => $contract_info['PremiumFees2'],
                '续签管理费' => $contract_info['ManagementFees2'],
                '续签GPS温控续费' => $contract_info['GPSFees2'],
                '续签费用合计' => $contract_info['TotalFees2'],
                '公司挂靠车货物保险' => $contract_info['PremiumFees3'],
                '公司挂靠车GPS温控设备费' => $contract_info['GPSFees3'],
                '公司挂靠车温控续费' => $contract_info['GPSFees3Sec'],
                '公司挂靠车优先车位' => $contract_info['PriorCount3'],
                '挂靠车租箱年费' => $contract_info['LeasingFeesYear4'],
                '挂靠车租箱季度费' => $contract_info['LeasingFeesQuarter4'],
                '挂靠车租箱优先车位' => $contract_info['PriorCount4'],
                '合同车租箱年费' => $contract_info['LeasingFeesYear5'],
                '合同车租箱季度费' => $contract_info['LeasingFeesQuarter5'],
                '合同车租箱优先车位' => $contract_info['PriorCount5'],
            ],
            self::CONTRACT_TYPE_YDHT => [
                '合同编号' => $contract_info['contract_no'],
                '甲方' => $contract_info['company_name'],
                '乙方' => $contract_info['se_name'],
                '货物信息' => $contract_info['goods_str'],
                '品类' => $contract_info['cat_name'],
                '重量' => $contract_info['weight'],
                '数量' => $contract_info['qty'],
                '货物总值' => $contract_info['total_price'],
                '发货地' => $contract_info['start_dp_name'],
                '目的地' => $contract_info['to_dp_nam'],
                '发车时间' => $contract_info['start_confirm_at'],
                '预计到达时间' => $contract_info['expect_time_end'],
                '接货人姓名' => $contract_info['to_dp_consignee'],
                '接货人电话' => $contract_info['to_dp_consignee_phone'],
                '车辆信息' => "车牌号：{$contract_info['car_no']};挂车：{$contract_info['car_no_hang']};车型：{$contract_info['car_model']}",
                '车牌号' => $contract_info['car_no'],
                '车架号' => $contract_info['vin'],
                '车型' => $contract_info['car_size_name'] . '米',
                '司机信息' => "姓名：{$contract_info['driver_name']};手机：{$contract_info['driver_mobile']};驾驶证：{$contract_info['driver_license']}",
                '司机' => $contract_info['driver_name'],
                '司机电话' => $contract_info['driver_mobile'],
                '驾驶证号' => $contract_info['driver_license'],
                '运费' => $contract_info['freight'],
                '结算方式' => $contract_info['settle_req_name'],
                '送风温度' => $contract_info['air_supply_start_temp'],
                '回风温度' => $contract_info['air_return_start_temp'],
            ],
            self::CONTRACT_TYPE_YDBCHT => [
                '合同编号' => $contract_info['contract_no'],
                '甲方' => $contract_info['company_name'],
                '乙方' => $contract_info['se_name'],
                '路桥费' => $contract_info['rb_fee'],
                '原发货地' => $contract_info['start_dp_name'],
                '原目的地' => $contract_info['to_dp_name'],
                '新发货地' => $contract_info['new_start_dp_name'],
                '新目的地' => $contract_info['new_to_dp_nam'],
                '增加运费' => $contract_info['add_freight'],
                '运单合同' => $contract_info['bill_contract_no'],
                '运单合同年' => $contract_info['bill_contract_year'],
                '运单合同月' => $contract_info['bill_contract_month'],
                '运单合同日' => $contract_info['bill_contract_day'],
            ],
            self::CONTRACT_TYPE_YDZFHT => [
                '合同编号' => $contract_info['contract_no'],
                '甲方' => $contract_info['company_name'],
                '乙方' => $contract_info['se_name'],
                '运单合同' => $contract_info['bill_contract_no'],
                '运单合同年' => $contract_info['bill_contract_year'],
                '运单合同月' => $contract_info['bill_contract_month'],
                '运单合同日' => $contract_info['bill_contract_day'],
            ],
        ];
        return isset($config_data[$contract_type]) ? $config_data[$contract_type] : [];
    }
    //合同参数end-----------------------------------------------------------------------------------------------------------------
}
